<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>基础利率列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<script type="text/javascript">
	var grid = null;
	var _mfrId;
	$(function () {
		var _url = '<%=path%>/rfbase/bscrateinfo/initList.do' ;
	    $("#ligergrid1").ligerGrid({
	    	url: _url,
	    	method : 'get',
	        columns: [
  	            { display: '操作', width: 100 ,height:'100px', align:'center',
	            	render: function (rowdata, rowindex, value){
	            		var h='<a href="javascript:modifyRow(';
	            		h+="'"+rowdata.id+"'";
	                    h+=')">修改</a>';
	                    h+=' | ';
	                    h+='<a href="javascript:deleteRow(';
	            		h+="'"+rowdata.id+"'";
	                    h+=')">删除</a>';
	                    
	                	return h;
	            	}
	            },
	            { display: '修改时间', name: 'mdfTm',align:'center', width: 100,render:renderDate},
	            { display: '半年利率(%)', name: 'halfY', align:'center', width: 80 },
	            { display: '一年利率(%)', name: 'oneY', align:'center', width: 80 },
	            { display: '三年利率(%)', name: 'threeY', align:'center', width: 80 },
	            { display: '五年利率(%)', name: 'fiveY', align:'center', width: 80 },
	            { display: '五年以上利率(%)', name: 'moreY',align:'center', width: 100 },
	            { display: '备注', name: 'rem',align:'center', width: 100 },
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        rownumbers:true,
	        fixedCellHeight:false
	    });
	    grid = liger.get("ligergrid1");
	    grid.setHeight(100);
	    $("#searchBar").ligerForm();
	    
	});
  	
	//删除数据
	function deleteRow(_id){
		if(!_id)return;
		var _ids = [];
		_ids.push(_id);
		$.ligerDialog.confirm('确定删除吗?', function (flag) {
			if(flag == false)return;
			var wait_dialog;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{ids:JSON.stringify(_ids)},
				url: '<%=path%>/rfbase/bscrateinfo/remove.do?id='+_id,
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
				success:function(msg){
					wait_dialog.close();
					 if(msg.success == 1){
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
						 grid.reload();
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
		});
	}
  	
  	//修改方法
  	function modifyRow(_id){
        $.ligerDialog.SQopen({
            cls: 'noBorder_Dialog',
            width: 400,
            height:320,
            title : '修改基础利率信息',
            url:'<%=path%>/rfbase/bscrateinfo/toAddPage.do?id='+_id,
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [{
	                text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', 
	                onclick: function (item, Dialog) {
	                    //在子页面里绑定 frameElement.dialog.onOk = function () {}
	                    if (Dialog.onOk) {
	                    	Dialog.onOk();
	                    }
        				grid.reload();
	                }
            		}, {
                    text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
            ]
        });
  	}
	
	//新增
	function add(){
		$.ligerDialog.SQopen({
            cls: 'noBorder_Dialog',
            width: 400,
            height:320,
            title : '新增基础利率信息',
            url:'<%=path%>/rfbase/bscrateinfo/toAddPage.do',
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [{
                    text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onOk = function () {}
                        if (Dialog.onOk) {
                        	Dialog.onOk();
                        }
                        grid.reload();
                        
                    }
                }, {
                    text: "取消", type: 'cancel', cls: 'l-dialog-btn-no', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
            ]
        });
	}
	
	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
	
	function search(){
		grid.reload();
	}
	
</script>

<body class="iframeBody">
	<div class="Wrapper">
		<div class="searchArea">
			<form id="searchBar">
				<div class="fieldset1 clearFix">
					<!-- <div class="clearFix"></div> -->
					<div class="btnsBox formBtns notRight">
						<span id="searchBtn" class="sq-button-round" onclick="search();">查询</span>
						<span id="addBtn" class="sq-button-round" onclick="add();">添加</span>
						<input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide" />
					</div>
			</form>
		</div>
	</div>
	<div id="ligergrid1" class="sq-grid"></div>


</body>
</html>